<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>引入计算属性</title>
</head>
<body>
<div id="app">
<!--  blur 监听元素失去焦点事件  -->
  <div>
    姓氏：<input type="text" name="familyName" id="familyName" v-on:keyup.enter="familyNameClicked" v-on:blur="familyNameClicked">
  </div>
  <div>
    名称：<input type="text" name="firstName" id="firstName" v-on:keyup.enter="firstNameClicked" v-on:blur="firstNameClicked">
  </div>

  <div>
    姓名全名：{{ familyName}} {{ firstName }}
  </div>
  <div>
    姓名全名：{{ fullName() }}
  </div>
  <div>
    姓名全名：{{ fullName() }}
  </div>
</div>
<script src="../../../../../js/vue.global.js"></script>
<script>
    const app = Vue.createApp({
        data(){
            return {
              firstName:null,
              familyName:null,
            }
        },
        methods:{
          familyNameClicked(){
            let family = document.getElementById("familyName")
            this.familyName = family.value
          },
          firstNameClicked(){
            let first = document.getElementById("firstName")
            this.firstName = first.value
          },

          fullName(){
            console.log("调用了 fullName 函数");
            return this.familyName + " " + this.firstName
          }
        }
    })

    app.mount("#app")
</script>
</body>
</html>